package com.wangys.controller;

import com.wangys.entities.Dfb;
import com.wangys.entities.Dft;
import com.wangys.mapper.DfbMapper;
import com.wangys.mapper.DftMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@ResponseBody
@CrossOrigin
@RequestMapping("/dft")
public class DftController {
    @Autowired(required = false)
    private DftMapper dftMapper;

    @RequestMapping("/select")
    public List<Dft> select(){
        return dftMapper.select();

    }
    @RequestMapping("/add")
    public void add(Dft dft){
        dftMapper.add(dft);
    }
    @RequestMapping("/delete")
    public void delete(int id){
        dftMapper.delete(id);
    }
    @RequestMapping("/byId")
    public List<Dft> byId(int id){
        return dftMapper.byId(id);
    }
    @RequestMapping("/update")
    public void update(Dft dft){
        dftMapper.update(dft);
    }
    @RequestMapping("/deleteAll")
    public void deleteAll(String ids){
        String[] split = ids.split(",");
        List<Integer> arrayList=new ArrayList<Integer>();
        for ( String iid:split) {
            arrayList.add(Integer.parseInt(iid));
        }
        dftMapper.deleteAll(arrayList);
    }
    @RequestMapping("/getCount")
    public List<Dft> getCount(){
       return dftMapper.getCount();
    }
    @RequestMapping("/like")
    public List<Dft> like(Dft dft){
         return dftMapper.like(dft);
    }
    }

